/**
 *  修改验收管理记录的panel
 */
Ext.ns('Ext.mc');

Ext.mc.Panel = Ext.extend(Ext.form.FormPanel,{
//	modal:true,
	cloasable : true,
	layout : 'form',
	autoScroll : true,
	buttonAlign : 'center',
	initComponent : function(){
		this.items = [{
		xtype : 'numberfield',
		fieldLabel:'ID',
		id : 'actualresultsid',
		name : 'actualRresult.actualresultsid',
		readOnly : true
	},{
		xtype:'textfield',
		fieldLabel : '项目编号',
		id : 'projectnumber',
		name : 'actualRresult.projectnumber',
		readOnly : true,
	},{
		xtype:'textfield',
		fieldLabel : '项目名称',
		readOnly : true,
		name : 'actualRresult.projectname',
		id:'projectname'
	},{
		xtype:'textfield',
		fieldLabel : '承担单位',
		readOnly : true,
		name : 'actualRresult.undertakeunit',
		id:'undertakeunit'
	},{
		xtype:'numberfield',
		fieldLabel : '发明专利申请',
		name : 'actualRresult.inventpatentapplication',
		id:'inventpatentapplication'
	},{
		xtype:'numberfield',
		fieldLabel : '发明专利授权',
		name : 'actualRresult.inventpatentauthorization',
		id:'inventpatentauthorization'
	},{
		xtype : 'numberfield',
		fieldLabel : '使用新型申请',
		name : 'actualRresult.usenewapplication',
		id:'usenewapplication'
	},{
		xtype : 'numberfield',
		fieldLabel : '使用新型授权',
		name : 'actualRresult.usenewauthorization',
		id:'usenewauthorization'
	},{
		xtype : 'numberfield',
		fieldLabel : '外观设计申请',
		name : 'actualRresult.appearancedesignapplication',
		id:'appearancedesignapplication'
	},{
		xtype : 'numberfield',
		fieldLabel : '外观设计授权',
		name : 'actualRresult.appearancedesignauthorization',
		id:'appearancedesignauthorization'
	},{
		xtype : 'numberfield',
		name : 'actualRresult.foreignpatent',
		fieldLabel : '外国专利',
		id:'foreignpatent'
	},{
		xtype : 'numberfield',
		name : 'actualRresult.newtechnology',
		fieldLabel : '新工艺',
		id:'newtechnology'
	},{
		xtype:'numberfield',
		name : 'actualRresult.newproduct',
		fieldLabel : '新产品',
		id:'newproduct'
	},{
		xtype:'textfield',
		name : 'actualRresult.newmaterial',
		fieldLabel : '新材料',
		id:'newmaterial'
	},{
		xtype:'numberfield',
		fieldLabel : '新装备',
		name : 'actualRresult.newequipment',
		id:'newequipment'
	},{
		xtype:'numberfield',
		name : 'actualRresult.computersoftware',
		fieldLabel : '计算机软件',
		id:'computersoftware'
	},{
		xtype:'numberfield',
		name : 'actualRresult.paper',
		fieldLabel : '论文论著',
		id:'paper'
	},{
		xtype:'numberfield',
		name : 'actualRresult.technologystandard',
		fieldLabel : '技术标准',
		id:'technologystandard'
	},{
		xtype:'numberfield',
		name : 'actualRresult.nationalaward',
		fieldLabel : '国家奖励',
		id:'nationalaward'
	},{
		xtype:'numberfield',
		name : 'actualRresult.provincialaward',
		fieldLabel : '省级奖励',
		id:'provincialaward'
	},{
		xtype:'numberfield',
		name : 'actualRresult.cityaward',
		fieldLabel : '市级奖励',
		id:'cityaward'
	},{
		xtype:'numberfield',
		name : 'actualRresult.doctor',
		fieldLabel : '博士',
		id:'doctor'
	},{
		xtype:'numberfield',
		name : 'actualRresult.master',
		fieldLabel : '硕士',
		id:'master'
	},{
		xtype:'numberfield',
		name : 'actualRresult.undergraduate',
		fieldLabel : '本科',
		id:'undergraduate'
	},{
		xtype:'numberfield',
		name : 'actualRresult.fundsavailable',
		fieldLabel : '到位经费',
		id:'fundsavailable'
	},{
		xtype:'numberfield',
		name : 'actualRresult.fundsinvestment',
		fieldLabel : '经费投入',
		id:'fundsinvestment'
	},{
		xtype:'numberfield',
		name : 'actualRresult.benefitacquired',
		fieldLabel : '已获效益',
		id:'benefitacquired'
	},{
		xtype:'textarea',
		name : 'actualRresult.projectsummary',
		fieldLabel : '项目总结',
		id:'projectsummary'
	}];
		this.buttons = [{
			xtype:'button',
			text:'确定',
			handler : function(b,e){
			var a = b.findParentBy(function(ct, cmp) { 
				return (ct instanceof Ext.mc.Panel) ? true : false; 
			});
			
			a.form.submit({
				url:'midCheck/updateResult.action',
				method : 'post',
				params:{

			},
				success : function(form,action){
					Ext.Msg.alert('提示','更新项目成果记录成功！');
//					a.form.reset();
			},
				failure : function(form,action){
					Ext.Msg.alert('提示','更新项目成果失败！请重新填写一遍。');
//					a.reset();
					getResult();
			}
			});
		}}];
		Ext.mc.Panel.superclass.initComponent.call(this);
}
});

function getResult(){
	
	Ext.Ajax.request({
		url : "midCheck/midCheckAction!getResult",
		success:function(r,o){
			var data = Ext.decode(r.responseText);
			if(data.success == false){
				Ext.Msg.alert('提示','未登录');
				return;
			}else{
				var a = data.list[0];
				var t = contentPanel.findById('addResult');
				t.findById('actualresultsid').setValue(a.actualresultsid);
				t.findById('projectnumber').setValue(a.projectnumber);
				t.findById('projectname').setValue(a.projectname);
				t.findById('undertakeunit').setValue(a.undertakeunit);
				t.findById('inventpatentapplication').setValue(a.inventpatentapplication);
				t.findById('inventpatentauthorization').setValue(a.inventpatentauthorization);
				t.findById('usenewapplication').setValue(a.usenewapplication);
				t.findById('usenewauthorization').setValue(a.usenewauthorization);
				t.findById('appearancedesignapplication').setValue(a.appearancedesignapplication);
				t.findById('appearancedesignauthorization').setValue(a.appearancedesignauthorization);
				t.findById('foreignpatent').setValue(a.foreignpatent);
				t.findById('newtechnology').setValue(a.newtechnology);
				t.findById('newproduct').setValue(a.newproduct);
				t.findById('newmaterial').setValue(a.newmaterial);
				t.findById('newequipment').setValue(a.newequipment);
				t.findById('computersoftware').setValue(a.computersoftware);
				t.findById('paper').setValue(a.paper);
				t.findById('technologystandard').setValue(a.technologystandard);
				t.findById('nationalaward').setValue(a.nationalaward);
				t.findById('provincialaward').setValue(a.provincialaward);
				t.findById('cityaward').setValue(a.cityaward);
				t.findById('doctor').setValue(a.doctor);
				t.findById('master').setValue(a.master);
				t.findById('undergraduate').setValue(a.undergraduate);
				t.findById('fundsavailable').setValue(a.fundsavailable);
				t.findById('fundsinvestment').setValue(a.fundsinvestment);
				t.findById('benefitacquired').setValue(a.benefitacquired);
				t.findById('projectsummary').setValue(a.projectsummary);
			}

	},
		failure:function(r,o){
			alert("failure");
	}
	});
	
}